package com.example.zhangxin.comevedio.activity.fragment;


import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.example.zhangxin.comevedio.R;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class HomeFragment extends BaseFragment implements View.OnClickListener {

    private Toolbar home_toolbar;
    private TabLayout home_tab;
    private ViewPager home_viewpager;
    private List<String> strs = new ArrayList<>();

    @Override
    protected void setData() {
        strs.add("关注");
        strs.add("热点");
        strs.add("最新");
        home_toolbar.setNavigationIcon(R.mipmap.ic_details);
        home_toolbar.setNavigationOnClickListener(this);
        home_viewpager.setAdapter(new FragmentPagerAdapter(getActivity().getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {

                return FragmentFactory.getFragment(position);
            }

            @Override
            public int getCount() {
                return 3;
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return strs.get(position);
            }

        });
        home_tab.setupWithViewPager(home_viewpager);

    }

    @Override
    protected void findView(View view) {
        home_toolbar = (Toolbar) view.findViewById(R.id.home_toolbar);
        home_tab = (TabLayout) view.findViewById(R.id.home_tab);
        home_viewpager = (ViewPager) view.findViewById(R.id.home_viewpager);


    }


    @Override
    public View getLayout() {
        return View.inflate(getActivity(),R.layout.fragment_home, null);
    }

    @Override
    public void onClick(View v) {

    }
}
